<?php

// $Id$

require_once(TANGRA_MAIN_DIR.'form/guardable_form.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/text/form_field_text.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/hidden/form_field_hidden.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/integer_limited/form_field_integer_limited.class.php');
require_once(TANGRA_MAIN_DIR.'/form/static_html_form_generator.class.php');


class Menu_Item_Form extends Guardable_Form {
	function __construct() {
		parent::__construct('menu_item', 'admin/menu/menu_item_edit.php');

		$f_label = new Form_Field_Text('label', true, 255);
		$this->add_field($f_label);

		$f_parent = new Form_Field_Hidden('parent', 0, true);
		$this->add_field($f_parent);

		$f_link = new Form_Field_Text('link', false, 255);
		$this->add_field($f_link);

		$f_hid = new Form_Field_Text('hid', true, 100);
		$f_hid->add_potential_error('invalid_hid');
		$f_hid->add_potential_error('not_unique');
		$this->add_field($f_hid);

		$f_target = new Form_Field_Text('target', false, 45);
		$this->add_field($f_target);

		$f_order = new Form_Field_Integer_Limited('order', 0, 1000, false, 4, 10);
		$this->add_field($f_order);
	}


	public function generate_html() {
		$html_gen = new Static_HTML_Form_Generator($this, 'modules/form_html_tpl_static_ajax_metallic_en', 'en');
		$html_gen->create_default_tpl_maps();
		$html_gen->change_field_p_error_map_entry('hid', 'invalid_hid', 'modules/admin_panel/forms/en/menu_item/field_error_invalid_hid.tpl');
		$html_gen->change_field_p_error_map_entry('hid', 'not_unique', 'modules/admin_panel/forms/en/menu_item/field_error_not_unique.tpl');

		printbr('<pre>');
		printbr(htmlentities($html_gen->get_static_html()));
		printbr('</pre>');
	}
}
